// inslude the SPI library:
#include <Flash.h>
#include <SPI.h>
#include <Serial.h>
#include <avr/interrupt.h>
#include <EEPROM.h>

Flash* nandFlash;

void setup() 
{
  Serial.begin(115200);
  nandFlash = new Flash();
}

void loop() 
{ 
  delay(1000);
  Serial.println("Accepting Data");
  while (1)
  {
    while (Serial.available() > 0)
    {
      Serial.println("Received Character");
      byte ch = Serial.read();
      
      if (ch == '+')
      {
        Serial.println();
        Serial.println("Dumping Array");
        nandFlash->dumpArray(64, 64 + 100, 10);
      } 
      else if (ch == '-')
      {
        Serial.println();
        Serial.println("Cache To Array");
        nandFlash->cacheToArray();
      }
      else
      {
        nandFlash->writeBytes(&ch, 1);
        Serial.write(ch);
      }
    } 
  }
}
